package main

import (
	"fmt"
	"sort"
)

func findMinDifference(timePoints []string) int {
	sort.Strings(timePoints)
	len := len(timePoints)
	min := 1440 + getMin(timePoints[0]) - getMin(timePoints[len-1])
	for i := 1; i < len; i++ {
		curMin := getMin(timePoints[i]) - getMin(timePoints[i-1])
		if curMin < min {
			min = curMin
		}
		if curMin == 0 {
			break
		}
	}
	return min
}

func getMin(t string) int {
	return (int(t[0]-'0')*10+int(t[1]-'0'))*60 + int(t[3]-'0')*10 + int(t[4]-'0')
}

func main() {
	fmt.Println(findMinDifference([]string{"00:00", "04:00", "22:00"}))
	fmt.Println(findMinDifference([]string{"14:49", "09:56", "01:02"}))
}
